//
// Created by xili on 2024/9/23 20:13.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    long long maximumTripletValue(vector<int> &nums) {
        long long ans = 0;
        int max_diff = 0, pre_max = 0;
        for (int x: nums) {
            ans = max(ans, (long long) max_diff * x);
            max_diff = max(max_diff, pre_max - x);
            pre_max = max(pre_max, x);
        }
        return ans;
    }
};
